//
//  LzwNewBetweenCell.m
//  NewHalfsugar
//
//  Created by 刘志武 on 16/1/6.
//  Copyright © 2016年 刘志武. All rights reserved.
//

#import "LzwNewBetweenCell.h"
#import "LzwBetweenCollectCell.h"



@implementation LzwNewBetweenCell

-(void)dealloc{
    
    [_myBetweenCollectionView release];
    [super dealloc];
    
}

-(void)setArrayColl:(NSMutableArray *)arrayColl{
    
    if (_arrayColl != arrayColl) {
        [_arrayColl release];
        _arrayColl = [arrayColl retain];
    }
    
    
    [self.myBetweenCollectionView reloadData];
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        [self creatCollectionSubView];
    }
    return self;
}

- (void)creatCollectionSubView{
    
    self.arrayColl = [NSMutableArray array];
    
    UICollectionViewFlowLayout *myFlowLayout = [[UICollectionViewFlowLayout alloc]init];
    
    myFlowLayout.itemSize = CGSizeMake(90, 90);
    
    myFlowLayout.sectionInset = UIEdgeInsetsMake(12, 12, 10, 10);
    myFlowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    myFlowLayout.minimumInteritemSpacing = 20;
    myFlowLayout.minimumLineSpacing = 20;
    
    self.myBetweenCollectionView = [[LzwbaseCollectView alloc]initWithFrame:CGRectMake(0, 0, 375, 120) collectionViewLayout:myFlowLayout];
//    self.myBetweenCollectionView.backgroundColor = [UIColor whiteColor];
    
    [self.contentView addSubview:self.myBetweenCollectionView];
    
    self.myBetweenCollectionView.dataSource = self;
    self.myBetweenCollectionView.delegate = self;
    
    [self.myBetweenCollectionView registerClass:[LzwBetweenCollectCell class] forCellWithReuseIdentifier:@"cell"];
    
    [self.myBetweenCollectionView reloadData];
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    NSLog(@"aaaaa = %ld", self.arrayColl.count);
    
    return self.arrayColl.count;
    
    
    
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    
    LzwBetweenCollectCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.modleCollect = [self.arrayColl objectAtIndex:indexPath.row];
    
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    LzwNewBetweenModle *model = [_arrayColl objectAtIndex:indexPath.row];
    
    [self.myLzwbetweenDelegata pushNewBetweenWebView:model.extend];
    
    
}




@end
